import subprocess
import sys

def install_requirements():
    try:
        subprocess.check_call([sys.executable, "-m", "pip", "install", "-r", "requirements.txt"])
        print("所有依赖库安装成功！")
    except subprocess.CalledProcessError:
        print("依赖库安装过程中出现错误，请手动检查并安装。")
        return False
    return True

if __name__ == "__main__":
    if install_requirements():
        try:
            # 替换为你的主程序文件名
            subprocess.run([sys.executable, "main_program.py"])
        except Exception as e:
            print(f"运行主程序时出现错误: {e}")